package com.ccsoft.atools.controller;

import com.ccsoft.atools.model.Projects;
import com.ccsoft.atools.service.ProjectsService;
import com.ccsoft.atools.service.ProjectsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName:ProjectsController
 * @Description:TODO
 * @Author:chanchaw
 * @Date:2019/11/12 15:56
 * @Version:1.0
 **/
@Api(tags = "ProjectsController", description = "项目列表接口集合")
@CrossOrigin
@RestController
@RequestMapping("/projects")
public class ProjectsController {

    @Autowired
    private ProjectsServiceImpl service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public int deleteByPrimaryKey(@PathVariable("iid") Integer iid) {
        return service.deleteByPrimaryKey(iid);
    }

    @PostMapping("/insert")
    public int insert(@RequestBody Projects record) {
        return service.insert(record);
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public Projects selectByPrimaryKey(@PathVariable("iid") Integer iid) {
        return service.selectByPrimaryKey(iid);
    }

    @GetMapping("/selectAll")
    public List<Projects> selectAll() {
        return service.selectAll();
    }

    @ApiOperation(value = "修改一行数据", notes = "post 方法，传入一个被修改的对象")
    @ApiImplicitParam(name = "record", defaultValue = "", value = "和数据库中表 projects 结构相同", required = true, paramType = "body")
    @PutMapping("/updateByPrimaryKey")
    public int updateByPrimaryKey(@RequestBody Projects record) {
        return service.updateByPrimaryKey(record);
    }


}
